/* CustomerController.java
 *
 * Copyright (C) 2013 Universidad de Sevilla
 * 
 * The use of this project is hereby constrained to the conditions of the 
 * TDG Licence, a copy of which you may download from 
 * http://www.tdg-seville.info/License.html
 * 
 */

package controllers;

import java.util.Collection;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import services.GalleryService;
import domain.Gallery;

@Controller
@RequestMapping("/gallery")
public class GalleryController extends AbstractController {

	//Services -----------------------------------------------------------------
	
	@Autowired
	GalleryService galleryService;
	
	// Constructors -----------------------------------------------------------

	public GalleryController() {
		super();
	}
	
	//List --------------------------------------------------------------------
	
	@RequestMapping("/list")
	public ModelAndView list(@RequestParam int customerId) {
		ModelAndView result;
		Collection<Gallery> galleries;
		galleries = galleryService.findGalleriesByCustomerId(customerId);
		
		
		result = new ModelAndView("gallery/list");
		result.addObject("galleries", galleries);
		result.addObject("URI", "/gallery/list.do");
		return result;
	}

	
}